from django.shortcuts import render
from django.db import connection


def index(request):
    # TODO: 获取游标对象
    cursor = connection.cursor()
    # TODO: 拿到游标对象后执行sql语句
    # cursor.execute('insert into book set name="三国演义",author="施耐庵"')
    # cursor.execute('insert into book set name="西游记",author="吴承恩"')
    # cursor.execute('insert into book set name="水浒传",author="罗贯中"')
    # cursor.execute('insert into book set name="红楼梦",author="曹雪芹"')
    cursor.execute('select * from book')
    rows = cursor.fetchall()
    for row in rows:
        print(row)
    return render(request, 'index.html')